#define  _CRT_SECURE_NO_WARNINGS
class Solution {
    int ret = 0;
    int t;
    void dfs(vector<int>& nums, int index, int path = 0) {
        if (index == nums.size()) {
            if (path == t)
                ret++;
            return;
        }
        dfs(nums, index + 1, path + nums[index]);
        dfs(nums, index + 1, path - nums[index]);
    }

public:
    int findTargetSumWays(vector<int>& nums, int target) {
        t = target;
        dfs(nums, 0);
        return ret;
    }
};